//
//  UIView+Screenshot.m
//  SportRing
//
//  Created by elwin on 10/30/14.
//  Copyright (c) 2014 HotOne. All rights reserved.
//

#import "UIView+Screenshot.h"
#import <QuartzCore/QuartzCore.h>

@implementation UIView (Screenshot)

- (UIImage *)screenshot:(BOOL)saveToLocal
{
    UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 2);
//    UIGraphicsBeginImageContext(self.frame.size);
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewScreenshotImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    if (saveToLocal)
    {
        UIImageWriteToSavedPhotosAlbum(viewScreenshotImage,nil,nil,nil);
    }
    
    return viewScreenshotImage;
}

@end
